package com.lintf.starter.initializer;

import com.lintf.starter.myService.MyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author lin tingfeng
 * @ system Mac
 * @ data 2025/6/10 17:06
 * @ package_name com.lintf.starter
 * @ project_name my-diy-project
 * @ desc
 */
@Slf4j
@Component
public class SystemRunner implements CommandLineRunner {

    @Autowired(required = false) // 如果没有注入成功，则为 null
    private MyService myService;

    @Override
    public void run(String... args) {
        log.info("SystemRunner 初始化开始...");
        if (myService == null) {
            log.error("自定义Starer包装配失败，请检查配置是否开启。");
            return;
        }
        log.info("SystemRunner 初始化完成，准备执行自定义逻辑...");
        log.info(myService.wrap("注入成功！"));
//        // 自定义SDK写法以及业务引用
//        try {
//            new FileUploader(
//                    "http://localhost:8080", // 替换为实际的上传服务地址
//                    "your-access-key" // 替换为实际的访问密钥
//            ).upload(new java.io.File("path/to/your/file.txt")); // 替换为实际的文件路径
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        }
        log.info("SystemRunner 执行完成");
    }
}
